package javaIoTest;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
import java.util.Scanner;

public class UdpClient {
	@SuppressWarnings("resource")  
    public static void main(String agrs[]) throws IOException {  
        String s = null;  
        while ((s =  new Scanner(System.in).nextLine()) != null) {  
            DatagramChannel dc = null;  
            dc = DatagramChannel.open();  
            SocketAddress address = new InetSocketAddress("localhost", 999);  
            ByteBuffer bb = ByteBuffer.allocate(255);  
            byte[] b = new byte[130];  
            b = s.getBytes();  
            bb.clear();  
            bb.put(b);  
            bb.flip();  
            dc.send(bb, address);  
        }
	}
}
